package io.renren.modules.hos.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.hos.service.DepartmentService;
import io.renren.modules.hos.vo.DoctorVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.hos.entity.DoctorEntity;
import io.renren.modules.hos.service.DoctorService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author ryf
 * @email 2559228480@qq.com
 * @date 2021-11-22 20:26:07
 */
@RestController
@RequestMapping("hos/doctor")
public class DoctorController {
    @Autowired
    private DoctorService doctorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("hos:doctor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = doctorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{doctorId}")
    @RequiresPermissions("hos:doctor:info")
    public R info(@PathVariable("doctorId") Integer doctorId){
		DoctorEntity doctor = doctorService.getById(doctorId);

        return R.ok().put("doctor", doctor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("hos:doctor:save")
    public R save(@RequestBody DoctorEntity doctor){
		doctorService.save(doctor);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("hos:doctor:update")
    public R update(@RequestBody DoctorEntity doctor){
		doctorService.updateById(doctor);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("hos:doctor:delete")
    public R delete(@RequestBody Integer[] doctorIds){
		doctorService.removeByIds(Arrays.asList(doctorIds));

        return R.ok();
    }

    /**
     * 查询医生信息
     * @return
     */
    @RequestMapping("/doctorInfo/{id}")
    public  R selectDoctorById(@PathVariable("id") Long doctorId){
        DoctorVo doctorVo = doctorService.selectDoctorById(doctorId);

        return R.ok().put("data", doctorVo);
    }
}
